home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / suncom.zip / SUNCOM.PAS < prev    next >
Pascal/Delphi Source File  |  1990-02-24  |  61KB  |  1,613 lines

  1. {$R-,V-,S-}
  2. PROGRAM SUN_Comm;
  3.  
  4. {$M 40000,0,45000}
  5.  
  6. USES
  7.    Crt, Dos, GlobType, PibTimer, PibAsync, Windows,
  8.    Ansidrv, Tpz, MyDos, TpStack, Printer;
  9.  
  10. CONST Max = 150;
  11.       MaxBuffer = 7168;
  12.       MaxBufferLimit = 6656;
  13.       Esc = #27;
  14.       On  = 1;
  15.       Off = 0;
  16.       Pause = 2;
  17.       Send = 1;
  18.       Receive = 0;
  19.       Open_Close : array[0..2] of String[5]
  20.                  = ('Close','Open ','Pause');
  21.       On_Off     : array[0..1] of String[3]
  22.                  = ('OFF ','ON');
  23.       Yes_No     : array[0..2] of String[3]
  24.                  = ('N','Y','Y');
  25.       Ctrl_Keys  : array['A'..'Z'] of Byte
  26.                  = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,
  27.                     23,24,25,26);
  28. TYPE
  29.     Str30 = String[30];
  30.     PathType = String[255];
  31.     BytePtr = ^BYTE;
  32.     PtrRec = RECORD
  33.                    Ofs,
  34.                    Seg : WORD;
  35.               END;
  36.     ProtocolRec = record
  37.                        Up,
  38.                        Down : PathType;
  39.                        Name : String[30];
  40.                        Flag : Integer;
  41.                   end;
  42.     ProtoArray = array['A'..'G'] of ProtocolRec;
  43.     FonBookRec = record
  44.                        Name      : Str30;
  45.                        Number    : Str30;
  46.                        BaudRate  : Word;
  47.                        Parity    : Char;
  48.                        DataBits  : Integer;
  49.                        StopBits  : Integer;
  50.                  end;
  51.     FonBookArray = Array[1..Max] of FonBookRec;
  52.     MacrosRec  = record
  53.                    Home_Key,
  54.                    End_Key,
  55.                    Up_Key,
  56.                    Down_Key,
  57.                    Left_Key,
  58.                    Right_Key,
  59.                    PageUp_Key,
  60.                    PageDown_Key,
  61.                    Ins_Key,
  62.                    Del_Key          : String;
  63.                 end;
  64.     ConfigRec = record
  65.                 BaudRate         : Word;             (* Baud rate for connection, e.g., 1200  *)
  66.                 ComPort          : Integer;          (* Which port, e.g., 1 for COM1:         *)
  67.                 Parity           : Char;             (* Parity, e.g., E for even parity       *)
  68.                 DataBits         : Integer;          (* How many bits per Character, e.g., 8  *)
  69.                 StopBits         : Integer;          (* How many stop bits -- nearly always 1 *)
  70.                 InBufSize        : Integer;          (* Size of input buffer                  *)
  71.                 OutBufSize       : Integer;          (* Size of output buffer                 *)
  72.                 Do_XonXoff       : Char;             (* 'Y' to do XON/XOFF flow control       *)
  73.                 Do_HardWired     : Char;             (* 'Y' to do XON/XOFF flow control       *)
  74.                 Do_CTS           : Char;             (* 'Y' to do CTS/RTS flow control        *)
  75.                 Do_DSR           : Char;             (* 'Y' to do DSR/DTR flow control        *)
  76.                 Do_Async_Status  : Byte;             (* Line error reporting off  *)
  77.                 Com_Addr_Str     : String[10];       (* Comm port address in hex string       *)
  78.                 Com_Addr         : Integer;          (* Comm port address                     *)
  79.                 Com_Irq          : Integer;          (* Comm port IRQ address                 *)
  80.                 Com_Int_No       : Integer;          (* Comm port interrupt vector number     *)
  81.                 LocalEcho        : Byte;
  82.                 DirectScreen     : Byte;
  83.                 MuteMode         : Byte;          (* No Sound *)
  84.                 LineFeeds        : Byte;
  85.                 ChatMode         : Byte;
  86.                 Protocols        : ProtoArray;
  87.                 FonBook          : FonBookArray;
  88.                 FilesPath        : String;
  89.                 HideStatusBar    : Byte;
  90.                 ToggleBackSpace  : Byte;
  91.                 Macros           : MacrosRec;
  92.             end;
  93.     BufferType = array[1..MaxBuffer] of Char;
  94.     BufferRec  = Record
  95.                     BufferArray    : BufferType;
  96.                     BufferCounter  : Integer;
  97.                     BufferFileName : String[12];
  98.                     BufferStatus   : Byte;
  99.                  end;
  100. VAR
  101.    CursorCol : Integer;
  102.    CursorRow : Integer;
  103.    WindowPtr : Pointer;
  104.  
  105. (************************************************************************)
  106. {$I suninc.inc}
  107. (************************************************************************)
  108.  
  109. PROCEDURE GetInt(VAR Number  : Integer;
  110.                      Mode    : Byte);
  111. VAR ExitOK  : Boolean;
  112.     Str6    : String[6];
  113.     Num     : LongInt;
  114.     X       : Integer;
  115. begin
  116.      ExitOK := FALSE;
  117.      Str6 := ' ';
  118.      repeat
  119.           case Mode of
  120.                0 : readln(Str6);
  121.                1 : read(Str6);
  122.           end; {Case}
  123.           val(Str6,Num,X);
  124.           if (Num <= 32767) and (Num >= -32767)
  125.              then ExitOK := TRUE;
  126.      until ExitOK = TRUE;
  127.      Number := Num;
  128. end;
  129.  
  130. (************************************************************************)
  131.  
  132. PROCEDURE GetChar(VAR Chars : Char;
  133.                       Mode  : Integer);
  134. begin
  135.      case Mode of
  136.          0 : Chars := Readkey;
  137.          1 : readln(Chars);
  138.          2 : read(Chars);
  139.      end; {case}
  140.      Chars := upcase(Chars);
  141. end;
  142.  
  143. (************************************************************************)
  144.  
  145. PROCEDURE GetStr(VAR TempStr : String;
  146.                      Mode    : Integer);
  147. begin
  148.      case Mode of
  149.          0 : readln(TempStr);
  150.          1 : read(TempStr);
  151.      end; {case}
  152. end;
  153.  
  154. (************************************************************************)
  155.  
  156. PROCEDURE Clear_Config(VAR Config : ConfigRec);
  157. VAR Lcv      : Integer;
  158.     Counter  : Char;
  159. begin
  160.     with Config do
  161.     begin
  162.     for Counter := 'A' to 'G' do
  163.     begin
  164.          Protocols[Counter].Up   := ' ';
  165.          Protocols[Counter].Down := ' ';
  166.          Protocols[Counter].Name := ' ';
  167.          Protocols[Counter].Flag := Off;
  168.     end;
  169.     for Lcv := 1 to Max do
  170.     begin
  171.         with FonBook[Lcv] do
  172.         begin
  173.            Name      := ' ';
  174.            Number    := ' ';
  175.            BaudRate  := 1200;
  176.            Parity    := 'N';
  177.            DataBits  := 8;
  178.            StopBits  := 1;
  179.         end;
  180.     end;
  181.     BaudRate        := 1200;         (* Baud rate for connection, e.g., 1200  *)
  182.     ComPort         := 1;            (* Which port, e.g., 1 for COM1:         *)
  183.     Parity          := 'N';          (* Parity, e.g., E for even parity       *)
  184.     DataBits        := 8;            (* How many bits per Character, e.g., 8  *)
  185.     StopBits        := 1;            (* How many stop bits -- nearly always 1 *)
  186.     InBufSize       := 1024;         (* Size of input buffer                  *)
  187.     OutBufSize      := 1024;         (* Size of output buffer                 *)
  188.     Do_XonXoff      := 'N';          (* 'Y' to do XON/XOFF flow control       *)
  189.     Do_HardWired    := 'N';          (* 'Y' to do XON/XOFF flow control       *)
  190.     Do_CTS          := 'N';          (* 'Y' to do CTS/RTS flow control        *)
  191.     Do_DSR          := 'N';          (* 'Y' to do DSR/DTR flow control        *)
  192.     Do_Async_Status := Off;         (* Line error reporting off              *)
  193.     Com_Addr_Str    := '02e8';       (* Comm port address in hex string       *)
  194.     Com_Addr := Hex_To_Dec( Com_Addr_Str , -1 );
  195.                                      (* Comm port address                     *)
  196.     Com_Irq         :=  4;           (* Comm port IRQ address                 *)
  197.     Com_Int_No      := -1;           (* Comm port interrupt vector number     *)
  198.                                      (* Use -1 if Not Sure                    *)
  199.     LocalEcho       := Off;
  200.     DirectScreen    := On;
  201.     MuteMode        := Off;          (* No Sound *)
  202.     LineFeeds       := Off;
  203.     ChatMode        := Off;
  204.     FilesPath       := 'C:\programs';
  205.     HideStatusBar   := Off;
  206.     ToggleBackSpace := Off;
  207.     with Macros do
  208.     begin
  209.     Home_Key        := ' ';
  210.     End_Key         := ' ';
  211.     Up_K